36#define WOLF_STATE_BLOCK_CREATE(StateBlockClass) \
37 static StateBlockPtr create(const Eigen::VectorXd& _state, bool _fixed) \
39 return std::make_shared<StateBlockClass>(_state, _fixed); \
41 static StateBlockPtr createIdentity(bool _fixed) \
43 return std::make_shared<StateBlockClass>(StateBlockClass::Identity(), _fixed); \
50class LocalParametrizationBase;
72class StateBlock :
public std::enable_shared_from_this<StateBlock>
83 LocalParametrizationBasePtr
103 LocalParametrizationBasePtr _local_param_ptr =
nullptr,
104 bool _transformable =
true);
113 const Eigen::VectorXd& _state,
115 LocalParametrizationBasePtr _local_param_ptr =
nullptr,
116 bool _transformable =
true);
141 void setState(
const Eigen::VectorXd& _state,
const bool _notify =
true);
208 void setZero(
bool _notify =
true);
210 virtual Eigen::VectorXd
identity()
const;
211 Eigen::VectorXd
zero()
const;
217 void perturb(
double amplitude = 0.1);
236 void plus(
const Eigen::VectorXd& _dv);
251 const Eigen::VectorXd& _state,
253 LocalParametrizationBasePtr _local_param_ptr,
257 state_size_(_state.size()),
259 local_param_ptr_(_local_param_ptr),
260 state_updated_(false),
262 local_param_updated_(false),
263 transformable_(_transformable)
271 LocalParametrizationBasePtr _local_param_ptr,
276 state_(
Eigen::VectorXd::Zero(_size)),
277 local_param_ptr_(_local_param_ptr),
278 state_updated_(false),
280 local_param_updated_(false),
281 transformable_(_transformable)
340 assert(
local_param_ptr_ !=
nullptr &&
"state block without local parametrization");
347 assert(_local_param !=
nullptr &&
"setting a null local parametrization");
class StateBlock
Definition: state_block.h:73
StateBlock & operator=(const StateBlock &o)=delete
StateBlock(StateBlock &&o)=delete
void perturb(double amplitude=0.1)
perturb all states states with random noise following an uniform distribution in [ -amplitude,...
Definition: state_block.cpp:47
std::string getType() const
Returns the type of the state block.
Definition: state_block.h:291
bool localParamUpdated() const
Return if local parameterization has been updated.
Definition: state_block.h:362
Eigen::VectorXd zero() const
Definition: state_block.h:402
void resetStateUpdated()
Set state_updated_ to false.
Definition: state_block.h:367
std::atomic_bool local_param_updated_
Flag to indicate whether the local_parameterization has been updated or not.
Definition: state_block.h:89
std::string type_
Type of the derived class.
Definition: state_block.h:76
bool isFixed() const
Returns if the state is fixed (not estimated)
Definition: state_block.h:313
bool isTransformable() const
Definition: state_block.h:219
SizeEigen getSize() const
Returns the state size.
Definition: state_block.h:302
void unfix()
Sets the state as estimated.
Definition: state_block.h:323
virtual void setIdentity(bool _notify=true)
Definition: state_block.h:387
void resetFixUpdated()
Set fix_updated_ to false.
Definition: state_block.h:372
bool transformable_
Flag to indicate if the state block can be transformed to another reference frame.
Definition: state_block.h:91
virtual void transform(const VectorComposite &_transformation)=0
void setNonTransformable()
Definition: state_block.h:229
bool isValid(double tolerance=Constants::EPS)
Definition: state_block.h:407
bool stateUpdated() const
Return if state has been updated.
Definition: state_block.h:352
LocalParametrizationBasePtr getLocalParametrization() const
Returns the state local parametrization ptr.
Definition: state_block.h:333
std::atomic_bool state_updated_
Flag to indicate whether the state has been updated or not.
Definition: state_block.h:86
void plus(const Eigen::VectorXd &_dv)
Definition: state_block.cpp:56
void setState(const Eigen::VectorXd &_state, const bool _notify=true)
Sets the state vector.
Definition: state_block.cpp:25
std::mutex mut_state_
State vector mutex.
Definition: state_block.h:81
Eigen::VectorXd getState() const
Returns the state vector.
Definition: state_block.h:296
StateBlock(const std::string &_type, const SizeEigen _size, bool _fixed=false, LocalParametrizationBasePtr _local_param_ptr=nullptr, bool _transformable=true)
Constructor from size.
Definition: state_block.h:268
void setZero(bool _notify=true)
Definition: state_block.h:392
virtual Eigen::VectorXd identity() const
Definition: state_block.h:397
void fix()
Sets the state as fixed.
Definition: state_block.h:318
SizeEigen getLocalSize() const
Returns the size of the local parametrization.
Definition: state_block.h:307
virtual ~StateBlock()
Destructor.
Definition: state_block.h:286
void setLocalParametrization(LocalParametrizationBasePtr _local_param)
Sets a local parametrization.
Definition: state_block.h:345
StateBlock(const StateBlock &o)=delete
void setTransformable(bool _trf=true)
Definition: state_block.h:224
Eigen::VectorXd state_
State vector storing the state values.
Definition: state_block.h:80
LocalParametrizationBasePtr local_param_ptr_
Local parametrization useful for optimizing in the tangent space to the manifold.
Definition: state_block.h:84
void removeLocalParametrization()
Removes the state_block local parametrization.
Definition: state_block.h:338
bool fixUpdated() const
Return if fix/unfix has been updated.
Definition: state_block.h:357
void setFixed(bool _fixed)
Sets the state status.
Definition: state_block.cpp:38
std::atomic_bool fix_updated_
Flag to indicate whether the status has been updated or not.
Definition: state_block.h:87
void resetLocalParamUpdated()
Set localk_param_updated_ to false.
Definition: state_block.h:377
std::atomic< SizeEigen > state_size_
State vector size.
Definition: state_block.h:79
double * getStateData()
Returns the state vector data array.
Definition: state_block.h:382
std::atomic_bool fixed_
Key to indicate whether the state is fixed or not.
Definition: state_block.h:77
bool hasLocalParametrization() const
Returns if the state has a local parametrization.
Definition: state_block.h:328
Definition: vector_composite.h:27
Namespace extending Eigen definitions.
Definition: wolf.h:94
const double EPS
Definition: wolf.h:74
Definition: capture_base.h:23
EIGEN_DEFAULT_DENSE_INDEX_TYPE SizeEigen
Vector and Matrices size type for the Wolf project.
Definition: wolf.h:58